# Maintainer: Takumi Takahashi <takumiiinn@gmail.com>
pkgname=apache-mod-auth-openidc
_pkgname=mod_auth_openidc
pkgver=2.4.4.1
pkgrel=0
pkgdesc="OpenID Connect Relying Party implementation for Apache HTTP Server 2.x"
url="https://www.mod-auth-openidc.org"
arch="all !s390x" # tests fails on s390x from cjose
license="Apache-2.0"
depends="apache2"
makedepends="apache2-dev musl-dev cjose-dev openssl-dev curl-dev hiredis-dev jansson-dev jq-dev pcre-dev oniguruma-dev"
subpackages="$pkgname-doc $pkgname-static"
source="https://github.com/zmartzone/mod_auth_openidc/releases/download/v$pkgver/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir"/$_pkgname-$pkgver

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--with-jq=/usr
	make
}

check() {
	make test
}

package() {
	mkdir -p "$pkgdir"/usr/lib/apache2
	/usr/share/apache2/build/instdso.sh SH_LIBTOOL='/usr/share/build-1/libtool' src/mod_auth_openidc.la "$pkgdir"/usr/lib/apache2
	/usr/share/build-1/libtool --mode=install install src/mod_auth_openidc.la "$pkgdir"/usr/lib/apache2

	mkdir -p "$pkgdir"/etc/apache2/conf.d
	cat <<- __EOF__ > "$pkgdir"/etc/apache2/conf.d/mod-auth-openidc.conf
	LoadModule auth_openidc_module modules/mod_auth_openidc.so

	__EOF__
	cat auth_openidc.conf >> "$pkgdir"/etc/apache2/conf.d/mod-auth-openidc.conf

	install -Dm644 README.md "$pkgdir"/usr/share/doc/"$pkgname"/README.md
}

sha512sums="fd551ba709221cbe20d1ed3eb80023a03b8d9e793f41cdfc6ab8e0cc165a3580632c31035a6cd43950b20e16b3da941d8f8e9c7f6b580c89b82f02ccb42d7e92  mod_auth_openidc-2.4.4.1.tar.gz"
